package com.example.gastometro;


import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class DbHelper extends SQLiteOpenHelper {


	private static final int DATABASE_VERSION = 1;
	private static final String DATABASE_NAME = "gastos4.db";
    public static final String TABLE_NAME = "gastos2";
	public static final String ID = "_id";
	public static final String NOME = "nome";
	public static final String LOCAL = "local";
	public static final String VALOR = "valor";
	public static final String DATA = "data";
	
	private static final String DATABASE_CREATE = "create table "
	+ TABLE_NAME + "( " + ID
	+ " integer primary key autoincrement, " + NOME
	+ " text not null, " + LOCAL + " text not null, "
	+ VALOR +" text not null" +
	", "+ DATA +" text not null);";
	
	public DbHelper(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
		//super()
	}
	
	 @Override
     public void onCreate(SQLiteDatabase db) {
             db.execSQL(DATABASE_CREATE);
     }
    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    	Log.w(DbHelper.class.getName(), "Upgrading database from version " + oldVersion + " to "	+ newVersion + ", which will destroy all old data");
    	db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
    		onCreate(db);
    }
}
